//
//  InvestmentViewController.m
//  wtshoppingcite
//
//  Created by TW on 15-3-24.
//  Copyright (c) 2015年 TW. All rights reserved.
//

#import "InvestmentViewController.h"

@interface InvestmentViewController ()<UIWebViewDelegate>

@property(nonatomic,strong)UIWebView *webView;
@property(nonatomic,strong)NSString *urlString;
@property(nonatomic,strong)UIActivityIndicatorView *activityIndicator;

@end

@implementation InvestmentViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setTitleView:@"投资理财"];
    
    
    NSString *html = @"http://wap.88mmmoney.com/index.htm";
    _webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, kWidth, kHeight-64)];
    [self.view addSubview:_webView];
    [_webView setUserInteractionEnabled:YES];  //是否支持交互
    [_webView setDelegate: self];     //委托
    
    //    NSString *urlStr = [_urlString urlEncoding];
    NSURL *url = [NSURL URLWithString:html];
    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    [_webView loadRequest:request];
    [self.view addSubview:_webView];
    
    
    _activityIndicator = [[UIActivityIndicatorView alloc]initWithFrame:CGRectMake(10,10,20,20)];//需要在.h文件中进行声明
    
    [_activityIndicator setCenter:_webView. center];//位置
    
    [_activityIndicator   setActivityIndicatorViewStyle: UIActivityIndicatorViewStyleGray];//颜色根据不同的界面自己调整
    
    [self.view  addSubview:_activityIndicator];
    // Do any additional setup after loading the view.
}


#pragma mark - webview
- (void)webViewDidFinishLoad:(UIWebView *)webView {
    
    _webView.hidden = NO;
    [_activityIndicator stopAnimating];
}

- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
    
    [_activityIndicator stopAnimating];
    //    [self showHUDWithString:@"网络错误！"];
    
    NSLog(@"error :%@",error);
    
}

- (void)webViewDidStartLoad:(UIWebView *)webView {
    [_activityIndicator startAnimating];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    ;
}


- (void)viewWillDisappear:(BOOL)animated
{
    
    [super viewWillDisappear:animated];
    
    
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
